#include "../include/nucManager.hpp"

int main(int argc, char** argv) {
	

  //ros::Rate loop_rate(5);
  ROS_INFO("Node nucManager launched.");
  
  ros::init(argc, argv, "nucManager");
  
  
  nucManager NUC;
  
  
  ros::Rate loop_rate(5);
  
  while (ros::ok())
  {
    ros::spinOnce();
    
    NUC.setFlag();
    
    NUC.publish();
    
    loop_rate.sleep();
  }
  
  
  return 0;
 
}


void nucManager::setFlag()
{

  if (quadBuffer.size() > 1)
  {
    //std::cout << "quadBuffer[0] = " << std::abs(quadBuffer[0] - quadBuffer[1]) << std::endl;
    //std::cout << "quadBuffer[1] = " << quadBuffer[1] << std::endl;
    
    if (std::abs( quadBuffer[0] - quadBuffer[1] ) > rotThreshold)
    {
      nuc_msg.data = 0;
    }
    else
    {
      nuc_msg.data = 1;
    }
  }
};

float nucManager::getStatus()
{
  return (float)nuc_msg.data;
}









